package com.molihub.mapper;

import com.molihub.entity.ArticleLike;
import com.molihub.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @InterfaceName: ArticleLike
 * @Description: 与文章点赞相关的数据库操作
 * @author: xw
 * @date 2020/2/1 19:12
 * @Version: 1.0
 **/
@Repository
@Mapper
public interface ArticleLikeMapper {
    /**
     * @return java.lang.Integer
     * @Description 根据文章id获得文章的总赞数
     * @Author xw
     * @Date 19:15 2020/2/1
     * @Param [articleId]
     **/
    public Integer getArticleTotalLikeCount(Integer articleId);

    /**
     * 添加一条用户给对应文章点赞的记录
     *
     * @param articleLike 点赞记录
     * @return java.lang.Integer
     * @author GGBOY
     * @date 2020/2/12
     */
    public Integer addLikeRecord(ArticleLike articleLike);

    /**
     * 根据文章ID查找给这篇文章点过赞的用户
     *
     * @param articleId 文章ID
     * @return java.util.List<com.molihub.entity.User> 点过赞的用户集合
     * @author GGBOY
     * @date 2020/2/12
     */
    public List<User> findLikeUsersByArticleId(Integer articleId);

    /**
     * 根据文章ID和用户ID查找对应的点赞记录
     *
     * @param userId 用户ID
     * @param articleId 文章ID
     * @return java.lang.Integer
     * @author GGBOY
     * @date 2020/2/23
     */
    public Integer getLikeRecordByUserAndArticleId(Integer userId, Integer articleId);

    /**
     * 根据文章ID和用户ID删除对应的点赞记录
     *
     * @param userId    用户ID
     * @param articleId 文章ID
     * @return void
     * @author GGBOY
     * @date 2020/2/23
     */
    public void deleteRecordByUserAndArticleId(Integer userId, Integer articleId);

}
